package com.liyiruo.tx.service.main11;

import com.liyiruo.tx.mapper.TableAMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

/**
 * 所有数据都不会存入数据库，因为在testMain发生异常时，父事务回滚则子事务也跟着回滚了
 *
 * @author liyiruo
 * @Description
 * @Date 2022/2/18 下午5:11
 */
@Service
public class TestMain11 {

    @Autowired
    private TableAMapper tableAMapper;
    @Autowired
    private TestBo testBo11;

    @Transactional(propagation = Propagation.REQUIRED)
    public void testMain() {
        tableAMapper.addTableA();  //调用A入参a1
        testBo11.testB();    //调用testB
        int i = 1 / 0;
    }
}
